package com.xingda.packing.dmds.minitor.controller;


import com.xingda.packing.dmds.common.BaseController;
import com.xingda.packing.dmds.common.R;
import com.xingda.packing.dmds.minitor.dto.PkAlarmDto;
import com.xingda.packing.dmds.minitor.service.IPkAlarmHistoryService;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController("pkAlarmHistoryDMDSController")
@RequestMapping("/api/alarmHistory")
public class PkAlarmHistoryController extends BaseController {

    @Resource
    IPkAlarmHistoryService pkAlarmHistoryService;

    @GetMapping("/getList/{area}")
    public R getList(@PathVariable int area) {

        try {
            List<PkAlarmDto> list = pkAlarmHistoryService.getList(area);
            list = CollectionUtils.isEmpty(list) ? new ArrayList<>() : list;
            return R.ok().put("data", list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.error();
    }
}

